package org.marsdonne.commons;

import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import java.util.Set;

public interface Validatable {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    Validator validator = factory.getValidator();

    default <T> Set<ConstraintViolation<T>> validate(T object) {
        return validator.validate(object);
    }
}
